//磨皮效果器的 Vertical Fragment shader 文件内容  
static const char* WHITENING_EFFECT_VERTICAL_FRAG_SHADER =
    "precision lowp float;																	\n"
	"varying highp vec2 fragTexCoord;	\n"
	"uniform sampler2D yuvTexSampler;	\n"
    "uniform highp float texCoordOffset;	\n"
    "uniform lowp float softLightBlendR;	\n"
    "uniform lowp float softLightBlendG;	\n"
    "uniform lowp float softLightBlendB;	\n"
    "uniform lowp float softLightBlendA;	\n"
	"uniform mediump float amplitude;	\n"
	"uniform mediump float edger;	\n"
	"void main()		\n"
	"{	\n"	
        "mediump vec4 color = texture2D(yuvTexSampler, fragTexCoord);	\n"
        "mediump vec2 blurMultiplyVec = vec2(0.0, texCoordOffset);		\n"
        "mediump vec3 Ixy = vec3(0.0, 0.0, 0.0);		\n"
        "mediump vec3 coefficientNum = vec3(0.0, 0.0, 0.0);		\n"
        "mediump vec3 gradSum = vec3(0.0, 0.0, 0.0);		\n"
        "mediump vec4 color_ver = vec4(0.0, 0.0, 0.0, 0.0);		\n"
        "mediump vec3 color_step = vec3(0.0, 0.0, 0.0);		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(-6.0) * blurMultiplyVec);		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.02;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(-5.0) * blurMultiplyVec);		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.03;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(-4.0) * blurMultiplyVec);		\n"
        "gradSum -= color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.05;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(-3.0) * blurMultiplyVec);		\n"
        "gradSum -= color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.09;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(-2.0) * blurMultiplyVec);		\n"
        "gradSum -= color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.12;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(-1.0) * blurMultiplyVec);		\n"
        "gradSum -= color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.15;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
"color_step = vec3(0.17,0.17,0.17);    \n"
        "Ixy += color.rgb * color_step;		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(1.0) * blurMultiplyVec);		\n"
        "gradSum += color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.15;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(2.0) * blurMultiplyVec);		\n"
        "gradSum += color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.12;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(3.0) * blurMultiplyVec);		\n"
        "gradSum += color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.09;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(4.0) * blurMultiplyVec);		\n"
        "gradSum += color_ver.rgb;		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.05;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(5.0) * blurMultiplyVec);		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.03;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "color_ver = texture2D(yuvTexSampler, fragTexCoord + vec2(6.0) * blurMultiplyVec);		\n"
        "color_step = step(abs(color_ver.rgb - color.rgb), vec3(amplitude));		\n"
"color_step = color_step * 0.02;    \n"
        "Ixy += (color_step * color_ver.rgb);		\n"
        "coefficientNum += color_step;		\n"
        "Ixy /= coefficientNum;		\n"
        "mediump vec3 grad = vec3(abs(gradSum.r), abs(gradSum.g), abs(gradSum.b)) * edger * 0.1;		\n"
        "mediump vec3 Txy = vec3(min(grad.r, 1.0), min(grad.g, 1.0), min(grad.b, 1.0));		\n"
        "color.rgb = mix(Ixy, color.rgb, Txy);		\n"
        "float highPassPixel = color.a;\n"
"highPassPixel = highPassPixel - 0.5;\n"
"float mixRatio = 0.8;\n"
"highPassPixel = mixRatio * highPassPixel;\n"
        "color.r = highPassPixel + color.r; \n"
"color.g = highPassPixel + color.g; \n"
"color.b = highPassPixel + color.b; \n"
"color.a = 1.0;\n"


//提亮
//"mediump vec4 overlay = vec4(0.6, 0.6, 0.6, 0.5);                                        \n"
//"mediump vec4 overlay = vec4(0.4, 0.4, 0.4, 0.3);                                        \n"
"mediump vec4 overlay = vec4(softLightBlendR, softLightBlendG, softLightBlendB, softLightBlendA);                                        \n"
"float alphaDivisor = color.a + step(color.a, 0.0);                                       \n"
"color = color * (overlay.a * (color / alphaDivisor) + (2.0 * overlay * (1.0 - (color / alphaDivisor)))) + overlay * (1.0 - color.a) + color * (1.0 - overlay.a);\n"

//提高对比度 Step1
//"color.r = color.r - sin(color.r * 6.2831853072) / 48.0;\n"
//"color.g = color.g - sin(color.g * 6.2831853072) / 48.0;\n"
//"color.b = color.b - sin(color.b * 6.2831853072) / 48.0;\n"
////提高对比度 Step2
"color.r = 1.1 * color.r - 0.1;\n"
"color.g = 1.1 * color.g - 0.1;\n"
"color.b = 1.1 * color.b - 0.1;\n"

        "gl_FragColor = vec4(color);		\n"
        "\n"
	"}\n";
